# -*- coding: utf-8 -*-
'''
@author: lowzoom
'''
from __future__ import division, print_function, unicode_literals
from _boot_dialog import Ui_Dialog
from boot import rna_handler, movie_handler, hosts_handler
import PyQt4.QtCore as qtc
import PyQt4.QtGui as qt

class BootDialog(qt.QDialog):
	'''
	启动选项对话诓
	'''
	def __init__(self, parent):
		qt.QWidget.__init__(self, parent)
		self.ui = Ui_Dialog()
		self.ui.setupUi(self)

		self.connect(self.ui.buttonBox, qtc.SIGNAL('accepted()'), self.take_effect)

	def exec_(self):

		rna_handler.load()

		self.ui.windowed_cbox.setChecked(rna_handler.is_windowed())
		self.ui.skip_lang_cbox.setChecked(rna_handler.is_skip_language_select())
		self.ui.skip_movie_cbox.setChecked(movie_handler.is_skip())
		self.ui.skip_connect_cbox.setChecked(hosts_handler.is_skip_connect())

		return super(BootDialog, self).exec_()

	def take_effect(self):
		
		rna_handler.set_windowed(self.ui.windowed_cbox.isChecked())
		rna_handler.set_skip_language_select(self.ui.skip_lang_cbox.isChecked())
		movie_handler.set_skip(self.ui.skip_movie_cbox.isChecked())
		hosts_handler.set_skip_connect(self.ui.skip_connect_cbox.isChecked())

		rna_handler.save()

		qt.QMessageBox.information(self, '提示', '设置成功!')
